package cn.kgc.service.impl;

import cn.kgc.mapper.DeptInfMapper;
import cn.kgc.pojo.DeptInf;
import cn.kgc.service.DeptService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("deptService")
public class DeptServiceimpl implements DeptService {
    @Resource
    DeptInfMapper deptInfMapper;


    @Override
    public int getCount(String NAME) {
        return deptInfMapper.getCount(NAME);
    }

    @Override
    public List<DeptInf> getDeptByPage(Integer currentPageNo, Integer pageSize, String NAME) {
        Integer pageNo = (currentPageNo-1)*pageSize;
        return deptInfMapper.getDeptByPage(pageNo,pageSize,NAME);
    }

    @Override
    public DeptInf getDeptById(Integer id) {
        return deptInfMapper.getDeptById(id);
    }

    @Override
    public boolean updateDept(DeptInf deptInf) {
        int count = deptInfMapper.updateDept(deptInf);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean addDept(DeptInf deptInf) {
        int count = deptInfMapper.addDept(deptInf);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean delId(Integer id) {
        int count = deptInfMapper.delId(id);
        if (count>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public DeptInf getDeptNAME(String NAME) {
        return deptInfMapper.getDeptNAME(NAME);
    }

    @Override
    public List<DeptInf> getDeptInfo() {
        return deptInfMapper.getDeptInfo();
    }
}
